package com.chtw.vuedemo.controller;

import com.chtw.vuedemo.bean.PhotoMenu;
import com.chtw.vuedemo.response.RespUtil;
import com.chtw.vuedemo.response.enumutil.CodeAndMsg;
import com.chtw.vuedemo.service.inf.PhotoMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chtw
 * @date 2020-10-04 20:15
 */
@RestController
@RequestMapping("/photo")
public class PhotoMenuController {
    @Autowired
    private PhotoMenuService photoMenuService;

    @GetMapping(value = "/menu/find")
    public RespUtil<List<PhotoMenu>> findAll(){
        try {
            return new RespUtil<>(CodeAndMsg.SUCCESS, photoMenuService.findAll(Sort.by("menu_id")));
        }catch (Exception e){
            System.out.println(e);
            return new RespUtil<>(CodeAndMsg.FAIL, null);
        }
    }
}
